<template>
  <div class="control-panel">
    <h3>地图控制</h3>
    <button @click="$emit('clear-highlight')">清除高亮</button>
    <button @click="$emit('update-layer')">刷新图层</button>
    
    <!-- 绘图工具按钮 -->
    <div class="draw-tools">
      <h4>绘图工具</h4>
      <button 
        @click="$emit('toggle-draw', 'Point')" 
        :class="{ active: currentDrawType === 'Point' }"
        style="margin-top: 5px;"
      >
        绘制点
      </button>
      <button 
        @click="$emit('toggle-draw', 'LineString')" 
        :class="{ active: currentDrawType === 'LineString' }"
      >
        绘制线(测距)
      </button>
      <button 
        @click="$emit('toggle-draw', 'Polygon')" 
        :class="{ active: currentDrawType === 'Polygon' }"
      >
        绘制面
      </button>
      <button @click="$emit('clear-drawings')" style="background-color: #ff9800;">
        清除绘图
      </button>
    </div>
    
    <button @click="$emit('go-home')" style="margin-top: 10px; background-color: #ff6b6b;">返回首页</button>
  </div>
</template>

<script>
import { defineComponent } from 'vue';

export default defineComponent({
  name: 'ControlPanel',
  props: {
    currentDrawType: {
      type: String,
      default: null
    },
    layerStatus: {
      type: String,
      default: '未加载'
    }
  },
  emits: ['clear-highlight', 'update-layer', 'toggle-draw', 'clear-drawings', 'go-home']
});
</script>

<style scoped>
.control-panel {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1000;
  background: white;
  padding: 15px;
  border-radius: 4px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  max-width: 300px;
}

.control-panel h3 {
  margin-top: 0;
  color: #333;
}

.control-panel h4 {
  margin: 10px 0 5px 0;
  color: #666;
}

.control-panel button {
  background: #1e88e5;
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  width: 100%;
  margin-top: 10px;
}

.control-panel button:hover {
  background: #1976d2;
}

.control-panel button.active {
  background: #4caf50;
  box-shadow: 0 0 5px rgba(76, 175, 80, 0.5);
}
</style>